package com.htz.agency.task;

import com.htz.agency.mapper.AnnouncementMapper;
import com.htz.agency.service.AnnouncementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author tang
 * @date 2025年06月28日 16:13
 */
@Component
@Slf4j
public class AnnouncementTask {
    @Autowired
    private AnnouncementService announcementService;

    /**
     * 处理删除公告
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void processDeleterAnnouncement(){
        log.info("处理删除公告：{}", new Date());
        boolean b = announcementService.deleteAll();
        if (b){
            log.info("处理删除公告成功：{}", new Date());
        }else{
            log.info("处理删除公告失败：{}", new Date());
        }
    }
    /**
     * 处理过期公告
     */

    @Scheduled(cron = "0 0 0 * * ?")
    public void processTimeoutAnnouncement(){
        log.info("处理过期公告：{}", new Date());
        boolean b = announcementService.expiredAnnouncement();
        if (b){
            log.info("处理过期公告成功：{}", new Date());
        }else{
            log.info("处理过期公告失败：{}", new Date());
        }
    }
}
